package com.dolphin.artifact.common.db;

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * Created by hhwf on 2017/10/18.
 */
@Configuration
public class DruidDataSourceConfig {


    private static final String DB_WRITE_PREFIX = "datasourcewrite";


    private static final String DB_READ_PREFIX = "datasourceread";

    @Bean(name = "dataSourceWrite")
    @Primary
    @ConfigurationProperties(prefix = DB_WRITE_PREFIX)
    public DataSource dataSource1() {
        return DataSourceBuilder.create().build();
    }




    @Bean(name = "dataSourceRead")
    @ConfigurationProperties(prefix = DB_READ_PREFIX)
    public DataSource dataSource2() {
        return DataSourceBuilder.create().build();
    }

}
